# $Id: PKGBUILD 87434 2013-03-31 19:18:48Z stephane $
# Maintainer: Stéphane Gaudreault <stephane@archlinux.org>

pkgbase=python-pyopencl
pkgname=('python2-pyopencl' 'python-pyopencl' 'pyopencl-headers')
pkgver=2012.1
pkgrel=8
pkgdesc="A complete, object-oriented language binding of OpenCL to Python"
arch=('i686' 'x86_64')
url="http://mathema.tician.de/software/pyopencl"
license=('custom')
makedepends=('ctags' 'python2-distribute' 'python-distribute' 'libcl' 'opencl-headers' 'mesa' 'boost>=1.53.0' 'python2-mako' 'python-mako' 'python-numpy' 'python2-numpy')
source=("http://pypi.python.org/packages/source/p/pyopencl/pyopencl-${pkgver}.tar.gz"
        'LICENSE.txt')
sha1sums=('ef2460d5e9b883d8afe0ec47863a243b6f8ac7ff'
          '2e6966b3d9b15603ce2c3ff79eeadd63c5d066b7')

build() {
   cd "$srcdir"

   cp -a pyopencl-$pkgver{,-python2}

   cd "${srcdir}/pyopencl-${pkgver}"
   python3 ./configure.py --cl-enable-gl --no-use-shipped-boost --boost-python-libname=boost_python3
   python3 setup.py build

   cd "$srcdir/pyopencl-$pkgver-python2"
   python2 ./configure.py --cl-enable-gl --no-use-shipped-boost
   python2 setup.py build
}

package_python-pyopencl() {
   depends=('libcl' 'opencl-headers' 'mesa' 'boost' 'python' 'python-numpy' 'python-mako' 'python-pytools' 'pyopencl-headers')

   cd "${srcdir}/pyopencl-${pkgver}"
   python3 setup.py install --prefix=/usr --root="${pkgdir}" --optimize=1 --skip-build

   rm -fr "${pkgdir}"/usr/include

   install -D -m644 ../LICENSE.txt "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
}

package_python2-pyopencl() {
   depends=('libcl' 'opencl-headers' 'mesa' 'boost' 'python2' 'python2-numpy' 'python2-mako' 'python2-pytools' 'pyopencl-headers')

   cd "${srcdir}/pyopencl-${pkgver}-python2"
   python2 setup.py install --prefix=/usr --root="${pkgdir}" --optimize=1 --skip-build

   rm -fr "${pkgdir}"/usr/include

   install -D -m644 ../LICENSE.txt "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
}

package_pyopencl-headers() {
   cd "${srcdir}/pyopencl-${pkgver}"
   install -dm755 "${pkgdir}"/usr/include/pyopencl

   for file in pyopencl-bessel-j.cl pyopencl-cephes.cl pyopencl-airy.cl pyopencl-ranluxcl.cl pyopencl-complex.h; do
      install -m644 src/cl/${file} "${pkgdir}"/usr/include/pyopencl
   done
}
